<template>
  <div>
    <div class="opt-area-02">
      <div class="right-con">
        <div class="input-frame">
          <Input type="text" @on-click="init()" placeholder="请输入姓名" style="width: 164px;margin-left: 5px;" v-model="params.user_name" icon="ios-search"/>
          <Input type="text" @on-click="init()" placeholder="请输入证件号" style="width: 164px;margin-left: 5px;" v-model="params.cardno" icon="ios-search"/>
        </div>
        <Button type="info" size="small" @click="selectData(1)" style="margin-top: 5px;margin-right:5px">搜索</Button>
        <Button type="warning" size="small" @click="handleSelectAll(true)" style="margin-top: 5px;margin-right:5px">设置全选</Button>
        <Button type="info" size="small" @click="handleSelectAll(false)" style="margin-top: 5px;margin-right:5px">取消全选</Button>
        <Button type="primary" size="small" @click="allDistribution()" style="margin-top: 5px;margin-right:5px">批量分配</Button>
        <Button type="warning" class="button-in" @click="upModal3()" size="small">导入人员信息</Button>
        <Button type="info" class="button-in" @click="upModal1()" size="small">添加人员信息</Button>
        <Button type="success" class="button-in" @click="uploadModel()" size="small">模板下载</Button>
      </div>
    </div>
    <div>
      <Table :columns="columns1" ref="selection" border :data="data1" @on-selection-change="changeSelect" size="small">
        <template slot-scope="{ index }" slot="index">
          <strong>{{ index + 1 }}</strong>
        </template>
        <template slot-scope="{ row }" slot="action">
          <Button type="info" size="small" style="margin-right: 5px;margin-bottom:2px" @click="distribution(row)">分配</Button>
          <Button type="primary" size="small" style="margin-right: 5px" @click="editPersonInfo(row)">编辑人员</Button>
        </template>
      </Table>
      <Row type="flex" justify="end" class="page_style">
        <Page :current="params.pageNo" :total="params.totalRecord" show-sizer :page-size="params.pageSize" show-total @on-change="pageAction" @on-page-size-change="pageSizeChange"/>
      </Row>
    </div>
    <Drawer title="分配信息" v-model="drawerModal" width="700" :styles="styles">
      <Row :gutter="32" class="mb20">
        <Col span="24">
          <h3>分配记录</h3>
        </Col>
      </Row>
      <Row :gutter="32">
        <Col span="24">
            <Table border :columns="columns3" :data="log_list" size="small" style="margin-bottom:10px;">
              <template slot-scope="{ row }" slot="vaccines_num">
                <span v-if="row.vaccines_num == '1'">第一针</span>
                <span v-if="row.vaccines_num == '2'">第二针</span>
                <span v-if="row.vaccines_num == '3'">第三针</span>
              </template>
              <template slot-scope="{ row }" slot="ym_zj_num">
                <span>{{row.ym_zj_num}}针剂</span>
              </template>
              <template slot-scope="{ row }" slot="inoculation_start_time">
                <span>{{row.inoculation_start_time}}-{{row.inoculation_end_time}}</span>
              </template>
              <template slot-scope="{ row }" slot="action">
                <Button class="table-action-btn" type="error" size="small" @click="cancelAppoint(row, 'edit')">取消分配</Button>
              </template>
            </Table>
        </Col>
      </Row>
      <Divider>分配信息</Divider>
      <Form :model="formData">
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="接种开始时间" label-position="top">
                      <DatePicker type="datetime" v-model="formData.inoculation_start_time" placeholder="请选择接种开始时间" style="width: 100%"></DatePicker>
                  </FormItem>
              </Col>
          </Row>
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="接种结束时间" label-position="right">
                      <DatePicker type="datetime" v-model="formData.inoculation_end_time" placeholder="请选择接种结束时间" style="width: 100%"></DatePicker>
                  </FormItem>
              </Col>
          </Row>
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="疫苗接种点" label-position="top">
                    <Select v-model="jzdData" placeholder="请选择接种点" filterable style="width: 100%" @on-change="changePoint(jzdData)">
                      <Option v-for="obj in inoculation_point_list" :value="JSON.stringify(obj)" :key="obj.id">{{obj.company_name}}{{obj.ym_company_code}}</Option>
                    </Select>
                  </FormItem>
              </Col>
          </Row>
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="疫苗批次号" label-position="top">
                    <Select v-model="ymdata" placeholder="请选择疫苗批次号" filterable style="width: 100%" @on-change="changeYm(ymdata)">
                      <Option v-for="obj in inoculation_list" :value="JSON.stringify(obj)" :key="obj.id">{{obj.ym_name}}，{{obj.ym_zj_num}}针剂，可预约数量：{{obj.ym_num - obj.ym_use_num}}</Option>
                    </Select>
                  </FormItem>
              </Col>
          </Row>
      </Form>
      <div class="demo-drawer-footer">
          <Button style="margin-right: 8px" @click="drawerModal = false">取消</Button>
          <Button type="primary" @click="submit">确定</Button>
      </div>
    </Drawer>
    <Drawer title="集体分配信息" v-model="drawerAllModal" width="30%" :styles="styles">
      <Form :model="formData">
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="接种开始时间" label-position="top">
                      <DatePicker type="datetime" v-model="formData.inoculation_start_time" placeholder="请选择接种开始时间" style="width: 100%"></DatePicker>
                  </FormItem>
              </Col>
          </Row>
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="接种结束时间" label-position="top">
                      <DatePicker type="datetime" v-model="formData.inoculation_end_time" placeholder="请选择接种结束时间" style="width: 100%"></DatePicker>
                  </FormItem>
              </Col>
          </Row>
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="疫苗接种点" label-position="top">
                    <Select v-model="jzdData" placeholder="请选择接种点" filterable style="width: 100%" @on-change="changePoint(jzdData)">
                      <Option v-for="obj in inoculation_point_list" :value="JSON.stringify(obj)" :key="obj.id">{{obj.company_name}}{{obj.ym_company_code}}</Option>
                    </Select>
                  </FormItem>
              </Col>
          </Row>
          <Row :gutter="32">
              <Col span="24">
                  <FormItem label="疫苗批次号" label-position="top">
                    <Select v-model="ymdata" placeholder="请选择疫苗批次号" filterable style="width: 100%" @on-change="changeYm(ymdata)">
                      <Option v-for="obj in inoculation_list" :value="JSON.stringify(obj)" :key="obj.id">{{obj.ym_name}}，{{obj.ym_zj_num}}针剂，可预约数量：{{obj.ym_num - obj.ym_use_num}}</Option>
                    </Select>
                  </FormItem>
              </Col>
          </Row>
      </Form>
      <div class="demo-drawer-footer">
          <Button style="margin-right: 8px" @click="drawerAllModal = false">取消</Button>
          <Button type="primary" @click="submitAll">确定</Button>
      </div>
    </Drawer>
    <Drawer title="人员信息" v-model="personModal" width="420" :styles="styles">
      <Form :model="personData">
        <Row :gutter="32">
          <Col span="24">
            <FormItem label="姓名" label-position="top">
              <Input v-model="personData.user_name" placeholder="请输入姓名" class="info-right"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="32">
            <Col span="24">
              <FormItem label="证件号" label-position="top">
                <Input v-model="personData.card_no" placeholder="请输入证件号" :disabled="what == 'edit'" class="info-right"/>
              </FormItem>
            </Col>
        </Row>
        <Row :gutter="32">
            <Col span="24">
                <FormItem label="电话号" label-position="right">
                  <Input v-model="personData.mobile" placeholder="请输入电话号" class="info-right"/>
                </FormItem>
            </Col>
        </Row>
        <Row :gutter="32">
            <Col span="24">
                <FormItem label="职业" label-position="right">
                  <Input v-model="personData.occupation" placeholder="请输入职业" class="info-right"/>
                </FormItem>
            </Col>
        </Row>
        <Row :gutter="32">
            <Col span="24">
                <FormItem label="企业" label-position="right">
                  <Select v-model="personData.enterprise_name" class="info-right" placeholder="请选择企业名称">
                    <Option v-for="item in enterpriseList" :value="item.qy_name" :key="item.id">{{ item.qy_name }}</Option>
                  </Select>
                </FormItem>
            </Col>
        </Row>
        <Row :gutter="32">
            <Col span="24">
                <FormItem label="具体地址" label-position="right">
                  <Input v-model="personData.address"  placeholder="请输入具体地址" class="info-right"/>
                </FormItem>
            </Col>
        </Row>
      </Form>
      <div class="demo-drawer-footer">
          <Button style="margin-right: 8px" @click="modal1 = false">取消</Button>
          <Button type="primary" @click="savePersonInfo">确定</Button>
      </div>
    </Drawer>
    <div v-if="modal">
      <Modal v-model="modal" width="100%" title="导入网格人员数据" @on-ok="confirm()">
       <dispose-excel ispose-excel :columns="columns" :url="url" :failedUrl="failedUrl"></dispose-excel>
      </Modal>
    </div>
    <Modal v-model="failPersonModal" title="分配失败提示">
      <p style="font-size: 16px;color: red;margin-bottom: 10px;">{{failedTitle}}</p>
      <div v-for="item in personList" v-bind:key="item.id">
        <Row>
          <Col span="16">
            <span>姓名：{{item.user_name}}；</span>
            <span>身份证号码：{{item.card_no}}</span>
          </Col>
        </Row>
      </div>
    </Modal>
    <Modal v-model="failPersonModal1" title="分配失败提示">
      <p style="font-size: 16px;color: red;margin-bottom: 10px;">{{failedTitle}}</p>
      <div v-for="item in personList1" v-bind:key="item.id">
        <Row>
          <Col span="16">
            <span>姓名：{{item.user_name}}；</span>
            <span>身份证号码：{{item.card_no}}</span>
          </Col>
        </Row>
      </div>
      <div v-for="item in personList2" v-bind:key="item.id">
        <Row>
          <Col span="16">
            <span>姓名：{{item.user_name}}；</span>
            <span>身份证号码：{{item.card_no}}</span>
          </Col>
        </Row>
      </div>
    </Modal>
  </div>
</template>

<script>
import { insertVaccination, updateVaccination, findqyPeopleList, findCommunityYMList, selectVillageNameList, saveEnterpriseFromYmc, findjzdsqListFromymc, date0str, findPeopleLogFromYmcList, updateCommunityTimeFromymc, saveEnterprisePeopleInfo, updateEnterprisePeopleInfo, findEnterpriseInfoNoPageList } from '@/api/yi-qing-fang-kong'
import DisposeExcel from '../dispose-excel/dispose-excel'
export default {
  name: 'personnel-information-list',
  components: { DisposeExcel },
  data () {
    return {
      failPersonModal1: false, // 9876
      jzdData: '',
      drawerAllModal: false, // 集体批量分配模态框
      personData: {},
      personModal: false,
      drawerModal: false,
      styles: {
        height: 'calc(100% - 55px)',
        overflow: 'auto',
        paddingBottom: '53px',
        position: 'static'
      },
      formData: {},
      columns1: [
        { type: 'selection', width: 60, align: 'center' },
        { title: '序号', type: 'index', width: 80, align: 'center' },
        { title: '姓名', key: 'user_name', width: 80, align: 'center' },
        { title: '身份证号', key: 'card_no', align: 'center' },
        { title: '电话号', key: 'mobile', width: 100, align: 'center' },
        { title: '职业', key: 'occupation', width: 100, align: 'center' },
        { title: '具体地址', key: 'address', align: 'center' },
        { title: '企业名称', key: 'qy_name', align: 'center' },
        { title: '操作', slot: 'action', width: 120, align: 'center' }
      ],
      columns: [
        { title: '姓名', key: 'user_name', align: 'center', fixed: 'left' },
        { title: '身份证号', key: 'cardno', align: 'center' },
        { title: '电话号', key: 'mobile', align: 'center' },
        { title: '职业', key: 'occupation', align: 'center' },
        { title: '具体地址', key: 'address', align: 'center' },
        { title: '企业名称', key: 'enterprise_name', align: 'center' }
      ],
      columns3: [ // 分配记录
        { title: '序号', type: 'index', width: 60, align: 'center' },
        { title: '姓名', key: 'name', width: 80, align: 'center' },
        { title: '当前针次', slot: 'vaccines_num', width: 100, align: 'center' },
        { title: '针剂', slot: 'ym_zj_num', width: 100, align: 'center' },
        { title: '接种时间段', slot: 'inoculation_start_time', align: 'center' },
        { title: '操作', slot: 'action', width: 90, align: 'center' }
      ],
      params: {
        user_name: '',
        cardno: '',
        pageNo: 1,
        pageSize: 10,
        totalRecord: 0
      },
      data2: {
        user_name: '',
        cardno: '',
        card_type: '',
        mobile: '',
        occupation: '',
        address: '',
        pick_garden: '',
        pick_vaccination: '',
        id: '',
        source_type: 1,
        del_flag: 0
      },
      data1: [],
      modal1: false,
      modal2: false,
      userList: [
        { value: '1', label: '身份证号' },
        { value: '2', label: '军官证' },
        { value: '3', label: '护照' },
        { value: '4', label: '港澳通行证' }
      ],
      cityList: [],
      modal: false,
      url: 'api/ac/xgc/enterpriseService/saveEnterprisePeopleInfo',
      failedUrl: '',
      inoculation_list: [],
      inoculation_point_list: [], // 疫苗接种点
      ymdata: '',
      personel_id: '',
      selectionList: '', // 勾选后人员信息列表
      paramData: {},
      name_str: '',
      personList: [], // 分配错误人员数据提示
      personList1: [], // 可分配错误人员数据提示
      personList2: [], // 已接种人员数据提示
      failPersonModal: false,
      failedTitle: '',
      log_list: [],
      enterpriseList: [], // 企业列表
      what: ''
    }
  },
  computed: {
    companyCode () {
      return this.$store.state.user.severUserInfo.company_code
    }
  },
  watch: {},
  mounted () {
    this.init()
    this.initCity()
  },
  methods: {
    cancelAppoint (item) { // 取消分配
      if (confirm('确定取消分配吗？')) {
        updateCommunityTimeFromymc({ id: item.id }).then(res => {
          console.log(res.data, '32424234')
          if (res.data.errcode === 0 && res.data.data.errcode === 0) {
            this.$Notice.success({
              title: '成功',
              desc: '取消分配成功'
            })
            this.drawerModal = false
          } else {
            this.$Notice.error({
              title: '失败',
              desc: res.data.data.errmsg
            })
            // this.drawerModal = false
          }
        })
      }
    },
    changeYm (item) { // 选择接种批次号
      console.log(JSON.parse(item), 'pici xinxi')
      this.paramData.ym_base_pici_id = JSON.parse(item).ym_pid
      this.paramData.ym_pid = JSON.parse(item).ym_pid
      this.paramData.id = JSON.parse(item).id
    },
    changePoint () { // 选择接种点
      console.log(JSON.parse(this.jzdData), '@@@')
      var item = JSON.parse(this.jzdData)
      this.paramData.appoint_code = item.ym_company_code
      findCommunityYMList({ company_code: this.companyCode, jzd_company_code: item.ym_company_code }).then(res => {
        if (res.data.errcode === 0) {
          this.inoculation_list = res.data.data.data
          console.log(this.inoculation_list, '@#$@#$#@$@')
        } else {
          this.$Notice.error({
            title: '查询批次列表失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    confirm () {
      this.modal = false
      this.init()
    },
    handleSelectAll (status) {
      this.$refs.selection.selectAll(status)
    },
    changeSelect (item) {
      console.log(item, '@@@')
      this.selectionList = item
    },
    distribution (item) { // 单人分配
      console.log(this.selectionList, '已选择')
      this.selectionList = []
      console.log(this.selectionList, '!!!!!!')
      this.selectionList.push(item)
      this.getInoculationPointList()
      this.getJzList(item.card_no)
      this.paramData = {}
      this.formData = {}
      this.ymdata = ''
      this.jzdData = ''
      this.drawerModal = true
      // this.personel_id = item.id
    },
    allDistribution () { // 集体预约弹出模态框
      if (this.selectionList.length > 0) {
        this.getInoculationPointList()
        this.paramData = {}
        this.formData = {}
        this.ymdata = ''
        this.jzdData = ''
        this.drawerAllModal = true
        // this.getInoculationData()
      } else {
        this.$Notice.error({
          title: '失败',
          desc: '请勾选预约人员'
        })
      }
    },
    getInoculationData () { // 获取接种点疫苗批次列表
      findCommunityYMList({}).then(res => {
        if (res.data.errcode === 0) {
          this.inoculation_list = res.data.data.data
          console.log(this.inoculation_list, '@#$@#$#@$@')
        } else {
          this.$Notice.error({
            title: '查询列表信息失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    getInoculationPointList () { // 获取接种点列表
      findjzdsqListFromymc({}).then(res => {
        if (res.data.errcode === 0) {
          this.inoculation_point_list = res.data.data.data
          console.log(this.inoculation_point_list, '接种点数据@#$@#$#@$@')
        } else {
          this.$Notice.error({
            title: '查询接种点列表失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    getJzList (card_no) { // 接种记录列表
      findPeopleLogFromYmcList({ card_no: card_no }).then(res => {
        if (res.data.errcode === 0) {
          this.log_list = res.data.data.data
          console.log(this.log_list.length, 'changsu')
          this.vaccines_num = this.log_list.length + 1
          console.log(this.inoculation_list, '@#$@#$#@$@')
        } else {
          this.$Notice.error({
            title: '查询列表信息失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    uploadModel () { // 模板下载
      window.open('http://imgdl.tripln.top/webhdfs/v1/importTemplate/企业人员批量导入模板_2512034229.xlsx?op=OPEN&namenoderpcaddress=hadoop01:9000&offset=0')
    },
    init () {
      findqyPeopleList(this.params).then((ret) => {
        if (ret.data.errcode === 0) {
          this.data1 = ret.data.data.results
          this.params.totalRecord = ret.data.data.totalRecord
        } else {
          this.$Notice.error({
            title: '查询信息失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    pageAction (page) {
      this.params.pageNo = page
      this.init()
    },
    selectData (inpageNo) { // 搜索
      if (inpageNo) {
        this.params.pageNo = inpageNo
      } else {
        this.params.pageNo = 1
      }
      this.init()
    },
    pageSizeChange (e) {
      this.params.pageSize = e
      this.selectData(this.params.pageNo)
    },
    submit () { // 分配
      if (this.formData.inoculation_start_time === '' || this.formData.inoculation_start_time === undefined) {
        const content = '<p>请选择疫苗接种开始时间</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      if (this.formData.inoculation_end_time === '' || this.formData.inoculation_end_time === undefined) {
        const content = '<p>请选择疫苗接种结束时间</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      if (this.paramData.ym_base_pici_id === '' || this.paramData.ym_base_pici_id === undefined) {
        const content = '<p>请选择疫苗接种批次</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      var param = {
        inoculation_start_time: date0str(this.formData.inoculation_start_time),
        inoculation_end_time: date0str(this.formData.inoculation_end_time),
        ym_base_pici_id: this.paramData.ym_base_pici_id,
        id: this.paramData.id,
        company_code: this.companyCode,
        peopleList: this.selectionList,
        appoint_code: this.paramData.appoint_code,
        vaccines_num: this.vaccines_num
      }
      saveEnterpriseFromYmc(param).then(res => {
        if (res.data.errcode === 0 && res.data.data.errcode === 0) {
          this.$Notice.success({
            title: '成功',
            desc: '疫苗分配成功'
          })
          this.drawerModal = false
          this.init()
        } else if (res.data.data.errcode === 9877) {
          this.personList = JSON.params(res.data.data.errmsg)
        } else if (res.data.errcode === 9876) {
        } else {
          this.$Notice.error({
            title: '失败',
            desc: res.data.data.errmsg
          })
        }
      })
    },
    submitAll () {
      if (this.formData.inoculation_start_time === '' || this.formData.inoculation_start_time === undefined) {
        const content = '<p>请选择疫苗接种开始时间</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      if (this.formData.inoculation_end_time === '' || this.formData.inoculation_end_time === undefined) {
        const content = '<p>请选择疫苗接种结束时间</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      if (this.paramData.appoint_code === '' || this.paramData.appoint_code === undefined) {
        const content = '<p>请选择接种点</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      if (this.paramData.ym_base_pici_id === '' || this.paramData.ym_base_pici_id === undefined) {
        const content = '<p>请选择疫苗接种批次</p>'
        this.$Modal.error({
          title: '错误',
          content: content
        })
        return
      }
      var param = {
        inoculation_start_time: date0str(this.formData.inoculation_start_time),
        inoculation_end_time: date0str(this.formData.inoculation_end_time),
        ym_base_pici_id: this.paramData.ym_base_pici_id,
        id: this.paramData.id,
        company_code: this.companyCode,
        peopleList: this.selectionList,
        appoint_code: this.paramData.appoint_code,
        vaccines_num: 1
      }
      saveEnterpriseFromYmc(param).then(res => {
        if (res.data.errcode === 0 && res.data.data.errcode === 0) {
          this.$Notice.success({
            title: '成功',
            desc: '疫苗分配成功'
          })
          this.drawerAllModal = false
          this.init()
        } else if (res.data.data.errcode === 9877) {
          this.personList = JSON.parse(res.data.data.errmsg).failed
          this.drawerAllModal = false
          this.failPersonModal = true
          this.failedTitle = '以下人员已经接种或预约，不可预约'
          this.init()
        } else if (res.data.data.errcode === 9876) {
          // this.personList1 = JSON.parse(res.data.data.errmsg).Flist // 可分配
          this.failedTitle = '以下人员已经接种或预约，不可预约'
          this.personList2 = JSON.parse(res.data.data.errmsg).noFList // 已经接种
          this.drawerAllModal = false
          this.failPersonModal1 = true
          // this.failedTitle = '以下人员已经预约过，但未进行接种，请在列表人员信息后面点击分配按钮单独进行每个人的分配'
          this.init()
        } else {
          this.$Notice.error({
            title: '失败',
            desc: res.data.data.errmsg
          })
        }
      })
    },
    upModal1 () { // 添加人员信息
      this.personData = {}
      this.getEnterpriseData()
      this.personModal = true
      this.what = 'add'
    },
    upModal3 () {
      this.modal = true
    },
    upModal2 (param) {
      this.modal2 = true
      this.data2.user_name = param.user_name
      if (param.card_type === '身份证号') {
        this.data2.card_type = '1'
      } else if (param.card_type === '军官证') {
        this.data2.card_type = '2'
      } else if (param.card_type === '护照') {
        this.data2.card_type = '3'
      } else {
        this.data2.card_type = '4'
      }
      this.data2.cardno = param.card_no
      this.data2.mobile = param.mobile
      this.data2.occupation = param.occupation
      this.data2.address = param.address
      this.data2.pick_garden = param.pick_garden
      this.data2.pick_vaccination = param.pick_vaccination
      this.data2.id = param.id
      this.data2.del_flag = param.del_flag
    },
    ok () {
      insertVaccination(this.data2).then((ret) => {
        if (ret.data.errcode === 0) {
          this.$Notice.success({
            title: '添加成功'
          })
          this.init()
        } else {
          this.$Notice.error({
            title: '添加失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    savePersonInfo () { // 手动输入添加人员信息
      var url = ''
      if (this.what === 'add') {
        url = saveEnterprisePeopleInfo
      } else if (this.what === 'edit') {
        url = updateEnterprisePeopleInfo
      }
      var param = {
        id: this.personData || '',
        user_name: this.personData.user_name,
        mobile: this.personData.mobile,
        occupation: this.personData.occupation,
        enterprise_name: this.personData.enterprise_name,
        address: this.personData.address,
        cardno: this.personData.card_no
      }
      url(param).then((ret) => {
        if (ret.data.errcode === 0) {
          this.$Notice.success({
            title: '成功',
            desc: '保存成功'
          })
          this.personModal = false
          this.init()
        } else {
          this.$Notice.error({
            title: '失败',
            desc: ret.data.errmsg
          })
          this.personModal = false
        }
      })
    },
    editPersonInfo (item) { // 编辑人员信息
      console.log(item, '人员信息')
      this.what = 'edit'
      this.getEnterpriseData()
      this.personData.id = item.id
      this.personData.card_no = item.card_no
      this.personData.user_name = item.user_name
      this.personData.enterprise_id = item.enterprise_id
      this.personData.address = item.address
      this.personData.mobile = item.mobile
      this.personData.occupation = item.occupation
      this.personModal = true
    },
    deleteRow (param) {
      this.data2.del_flag = '1'
      this.data2.user_name = param.user_name
      this.data2.card_type = param.card_type
      this.data2.cardno = param.card_no
      this.data2.mobile = param.mobile
      this.data2.occupation = param.occupation
      this.data2.address = param.address
      this.data2.pick_garden = param.pick_garden
      this.data2.pick_vaccination = param.pick_vaccination
      this.data2.id = param.id
      updateVaccination(this.data2).then((ret) => {
        if (ret.data.errcode === 0) {
          this.$Notice.success({
            title: '删除成功'
          })
          this.init()
        } else {
          this.$Notice.error({
            title: '删除失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    initCity () {
      selectVillageNameList().then((ret) => {
        if (ret.data.errcode === 0) {
          this.cityList = ret.data.data
        } else {
          this.$Notice.error({
            title: '查询信息失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getEnterpriseData () { // 获取企业信息下拉数据
      findEnterpriseInfoNoPageList().then((ret) => {
        if (ret.data.errcode === 0) {
          console.log(ret.data, '企业信息')
          this.enterpriseList = ret.data.data
        } else {
          this.$Notice.error({
            title: '失败',
            desc: ret.data.errmsg
          })
        }
      })
    }
  }
}
</script>

<style scoped>
  .opt-area-02 .right-con {
    width: 100%;
    margin-top: 5px;
    display: flex;
  }

  .opt-area-02 .right-con input {
    width: 150px;
    margin-right: 10px;
  }

  .button-in {
    width: 100px;
    margin-top: 5px;
    margin-left: 5px;
  }

  .opt-area-02 .right-con .input-frame {
    width: 100%;
    margin-right: 10px;
  }

  .opt-area-02 {
    display: flex;
    align-items: center;
    flex-direction: column;
    border: 1px solid #abdcff;
    background-color: #f0faff;
    padding: 8px 16px 8px 16px;
    border-radius: 4px;
    margin-bottom: 10px;
  }
  .info-left{
    margin-left: 5px;
    margin-top: 5px;
    margin-bottom: 5px;
  }
  .info-right{
    margin-right: 5px;
    margin-top: 5px;
    margin-bottom: 5px;
  }
  .demo-drawer-footer{
      width: 100%;
      position: absolute;
      bottom: 0;
      left: 0;
      border-top: 1px solid #e8e8e8;
      padding: 10px 16px;
      text-align: right;
      background: #fff;
  }
</style>
